"""oldblog URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include, re_path
from django.views.static import serve

from blog import views, backend
from oldblog import settings

urlpatterns = [
    path('admin/', admin.site.urls),
    path('blog/', include('blog.urls', namespace='blog')),
    path('login/', views.login, name='login'),
    path('logout/', views.logout, name='logout'),
    path('get_validcode_img/', views.get_validcode_img, name='get_validcode_img'),
    path('register/', views.register, name='register'),
    path('index/', views.index, name='index'),
    # 后台管理页面
    path('cn_backend/', backend.cn_backend, name='cn_backend'),
    path("cn_backend/add_article/", backend.add_article, name='add_article'),
    # 点赞页面
    path('digg/', views.digg, name='digg'),
    # 评论
    path('comment/', views.comment, name='comment'),
    path('get_comment_tree/', views.get_comment_tree, name='get_comment_tree'),
    # 默认站点首页
    path('', views.index),
    # media path config
    re_path(r'media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
    path('upload/', backend.upload, name='upload'),
    # django 2以上版本两种写url的方式
    # 个人站点的跳转
    re_path(r"^(?P<username>\w+)/(?P<condition>tag|category|archive)/(?P<param>.*)/$", views.home_site,
            name='home_site2'),
    # path("<str:username>/<str:tag|category|archive>/<str:*>/",views.home_site),
    # 个人站点的url
    # re_path(r"^(?P<username>\w+)/",views.home_site),
    path('<str:username>/', views.home_site, name='home_site'),
    path('<str:username>/article/<int:pk>', views.article_detail, name='article_detail'),

]
